home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / oxcc1434.zip / SRC / CFF.H < prev    next >
C/C++ Source or Header  |  1995-11-26  |  25KB  |  815 lines

  1. /* CFF.H    -- user api include file for the cff library */
  2.  
  3. #define CALLER(a) (((unsigned*)&a)[-1])
  4.  
  5. #if defined(__GNUC__) || defined(__OXCC__)
  6. #ifndef __ITEMH__
  7. #define __ITEMH__
  8. typedef unsigned long long  KeyItem;   /* type for a key's associated item */
  9. #endif
  10. #endif
  11.  
  12. typedef union             /* 2 BYTES */
  13.     {
  14.         unsigned short val;
  15.         unsigned char b[2];
  16. } SVAL;
  17.  
  18. typedef union            /* 4 BYTES */
  19.     {
  20.     unsigned long a0;
  21.     void *a1;
  22.     struct
  23.         {
  24.         SVAL    lo_word;
  25.         SVAL    hi_word;
  26.         } a2;
  27.     struct
  28.         {
  29.             unsigned int pad :28;
  30.             unsigned int type :4;
  31.         } a3;
  32.     struct
  33.         {
  34.             unsigned char b[4];
  35.         } a4;
  36.     int a8;
  37.     short a9;
  38.     char a10;
  39.     float a11;
  40. } ADDR;
  41.  
  42. #ifndef __STORH__
  43. #define __STORH__
  44.  
  45. typedef union _stor    /* 8 BYTES */
  46.     {
  47.     unsigned long    a0;
  48.     void *a1;
  49. #if defined(__GNUC__) || defined(__OXCC__)
  50.     KeyItem item;
  51. #endif
  52.     struct
  53.         {
  54.         unsigned short    lo_word;
  55.         unsigned short    hi_word;
  56.         unsigned int size :28;        /* in bytes or nibbles */
  57.         unsigned int type :4;        /* describes the STOR type */
  58.         } a2;
  59.     struct
  60.         {
  61.             short s0;
  62.             short s1;
  63.             short s2;
  64.             short s3;
  65.         } a3;
  66.     struct
  67.         {
  68.             unsigned long    s0;
  69.             unsigned long    s1;
  70.         } a4;
  71.     struct
  72.         {
  73.             unsigned char    b[8];
  74.         } a5;
  75. #if    defined(__GNUC__) || defined(__OXCC__)
  76.     struct
  77.         {
  78.             unsigned long long dupname :48;
  79.             unsigned long long dupid :16;
  80.         } a6;
  81. #endif
  82.     struct
  83.         {
  84.             unsigned int home : 30;
  85.             unsigned int full : 2;
  86.         } a7;
  87.     int a8;
  88.     short a9;
  89.     char a10;
  90.     float a11;
  91.     double a12;
  92. } STOR, Item;
  93. #endif /* __STORH__ */
  94.  
  95. /* DEFINITIONS FOR "a2.type */
  96. #define STO_INACTIVE (0)
  97. #define STO_NIL  (1)
  98. #define STO_VALUE (2)    
  99. #define STO_CHUNK (3)
  100. #define STO_KEYINFO (4)
  101. #define STO_NILCHUNK (5)
  102. #define STO_COMPCHUNK (6)
  103. #define STO_ALLOCATED (7)
  104. #define STO_DELETED (8)    /* always ored with non zero */
  105. #define STOMASK (7)
  106.  
  107. typedef struct {
  108.     unsigned long    name;
  109.     unsigned short    xname;
  110.     unsigned short    id;
  111. } DupName;
  112.  
  113. typedef struct            /* 12 BYTES */
  114.     {
  115.         STOR c0;
  116.         ADDR c1;
  117.     } CAT;
  118. #define CATEXACT  (8)
  119. #define CATHASH (cat.c1.a0)
  120.  
  121. typedef struct    /* 20 bytes */
  122.     {
  123.         STOR    stor;
  124.         CAT        cat;
  125. } SDB;
  126.  
  127.  
  128. /* DEFINE CFF OPEN MODES */
  129.  
  130. #define F_RDONLY    (0x0001)
  131. #define F_WRONLY    (0x0002)
  132. #define F_RDWR        (0x0003)
  133. #define F_CREAT        (0x0004)
  134. #define F_TEMP        (0x0008)
  135. #define F_UNIQ        (0x0010)
  136. #define F_EXCL        (0x0020)
  137. #define F_BITMAP    (0x0040)
  138. #define F_TRUNC        (0x0080)
  139. #define F_APPEND    (0x0100)
  140. #define F_DELETING    (0x0200)
  141. #define F_FILEONLY    (0x0400)
  142. #define F_BIGDIR    (0x0800)
  143. #define F_HUGEDIR    (0x1000)
  144. #define F_SETUP        (0x4000)
  145. #define F_PARENTS    (0x4000)
  146. #define F_SORTED    (0x8000)
  147. #define F_UNTAGGED    (0x10000)
  148. #define F_STAT        (0x20000)    /* TRULY READONLY */
  149. #define F_TEXT        (0x40000)    /* DOS crap, default mode is binary */
  150. #define F_ZIPFILE    (0x80000)    /* compress the file aspect */
  151. #define F_ZIPDATA    (0x100000)    /* compress data chunks */
  152. #define F_TEMPFILE    (F_RDWR|F_CREAT|F_UNIQ|F_TEMP)
  153.  
  154. /* BUFFER RELEASE MODES */
  155. #define R_DIRTY        (0x80000000)
  156. #define R_CLEAN        (0x40000000)
  157. #define R_FLUSH        (0x20000000)
  158.  
  159. /* DEFINE SOME SYSTEM CALL VALUES */
  160. #define S_READBLK (1)
  161. #define S_WRITEBLK (2)
  162. #define S_GETSPACE (3)
  163. #define S_GIVESPACE (4)
  164. #define S_CLOSE (5)
  165. #define S_OPEN (6)
  166. #define S_CREATE (7)
  167. #define S_UNLINK (8)
  168. #define S_SEEK (9)
  169. #define S_FLUSH (10)
  170. #define S_CLOSETRUNC (11)
  171.  
  172. #define S_SET (0)
  173. #define S_CUR (1)
  174. #define S_END (2)
  175.  
  176. /* DEFINE CFF OBJECT PROPERTIES -- returned by cfobtype(void *something) */
  177. #define OB_SHARE    (0x00000001)
  178. #define OB_ISDIR    (0x00000002)
  179. #define OB_BMOK        (0x00000004)
  180. #define OB_SMOK        (0x00000008)
  181. #define OB_MEM        (0x00000010)
  182. #define OB_RAWDEV    (0x00000020)
  183. #define OB_CFILE    (0x00000040)
  184. #define OB_SETUP    (0x00000080)
  185. #define OB_FOD        (0x00000100)
  186. #define OB_ROOTDIR    (0x00000200)
  187. #define OB_DIRTY    (0x00000400)
  188. #define OB_DELCLOSE    (0x00000800)
  189. #define OB_WRITE    (0x00001000)
  190. #define OB_BITMAP    (0x00002000)
  191. #define OB_XFILE    (0x00004000)
  192. #define OB_ISNEW    (0x00008000)
  193. #define OB_SMEM        (0x00010000)
  194. #define OB_FILEONLY    (0x40000000)
  195. #define OB_HASHDIR    (0x20000000)
  196. #define OB_TREEDIR    (0x10000000)
  197. #define OB_UNTAGGED (0x08000000)
  198. #define OB_PREALLOC (0x01000000)
  199. #define OB_ZIPFILE    (0x00800000)
  200. #define OB_ZIPDATA    (0x00400000)
  201. #define OB_CHUNK    (0x00200000)
  202. #define OB_VALUE    (0x00100000)
  203.  
  204. #ifndef NULL
  205. #define NULL ((void *)0)
  206. #endif
  207. #ifndef EOF
  208. #define EOF     (-1)
  209. #endif
  210. #define YES     (1)
  211. #define NO      (0)
  212. #define OK      (1)
  213. #define NODUPS    (0)
  214. #define OKDUPS    (1)
  215. #define CNTDUPS (2)
  216. #define DUPNAMES (4)
  217.  
  218. #define PREALLOC1 (8)
  219. #define PREALLOC2 (16)
  220. #define PREALLOC3 (32)
  221.  
  222. #define ERROR   (-1)
  223. #define FOUND    (1)
  224. #define NOTFOUND (0)
  225. #define NONE    (-1)    /* no value */
  226. #define INVALID (-4)    /* invalid value */
  227. #define LESS    (-1)    /* a is less than b */
  228. #define EQUAL    (0)        /* a and b are equal */
  229. #define GREATER    (2)        /* a is greater than b */
  230. #define    BOI    (-2)        /* beginning of index */
  231. #define    EOI    (-3)        /* end of index */
  232.  
  233. typedef struct opninfo {
  234.     long initial_entries;
  235.     unsigned long bitmap_prealloc;
  236.     long data_prealloc;
  237. } OPNINFO;
  238.  
  239. typedef struct cfdirent {
  240.     int d_namlen;
  241.     char *d_name;
  242.     unsigned long d_bytesalloc;
  243.     unsigned long d_bytesused;
  244.     unsigned long d_mode;
  245.     unsigned long d_entrycnt;
  246.     unsigned long d_ino;
  247.     unsigned long d_mtime;
  248.     unsigned long d_ctime;
  249.     void *d_fpt;
  250. } CFDIRENT;
  251.  
  252. /* Function codes for the cfmisc instruction */
  253. enum CfMisc {
  254.     CF_ALLOC,CF_USED,CF_DEPTH,CF_MARK,CF_HEAD,CF_TAIL,CF_NEXT,
  255.     CF_PREV,CF_KEYLEN,CF_DATALEN,CF_MODBUFS,
  256.     CF_CURBUFS,CF_SETKEYCMP,CF_SETITEMCMP,CF_SETERRFUNC,
  257.     CF_LAZY,CF_VERYLAZY,CF_CLRLAZY,CF_ISNEW,CF_FLUSH,
  258.     CF_FILESIZE,CF_FILEALLOC,CF_PREALLOC,CF_ALIGNMENT,
  259.     CF_MAPSIZE,CF_ISSORTED,CF_KEY,CF_ITEM,CF_CREEP,
  260.     CF_SETPRINTFUNC,CF_DATA,CF_GETMARK,CF_SETMARK
  261. };
  262.  
  263. typedef struct cffstat {
  264.         unsigned long    st_smhead;
  265.         unsigned long    st_smtail;
  266.         unsigned short    st_id;
  267.         unsigned short    st_keysize;
  268.  
  269.         STOR           st_dups;
  270.         unsigned long  st_bmhead;
  271.         unsigned long  st_bmtail;
  272.         unsigned long  st_mode;
  273.         short st_uid;
  274.         short st_gid;
  275.         long  st_mtime;
  276.         long  st_ctime;
  277.  
  278.         unsigned long  st_highleaf;
  279.         unsigned long  st_size;
  280.         unsigned long  st_alloc;
  281.         unsigned long  st_entrycnt;
  282.         short            st_mapsize;
  283.         unsigned short st_dupids;
  284.  
  285.         long  st_atime;
  286.         long  st_filesize;
  287.         long  st_filealloc;
  288.         long  st_obtype;
  289.         unsigned int st_filedups;
  290.         long  st_ino;
  291.         short st_blksize;
  292.         short st_dev;
  293.         short st_nlink;
  294.         short st_rdev;
  295. } CFSTAT;
  296.  
  297. /* MODE BITS */
  298. #define M_AFMT        (0x30000000)
  299. #define M_ROOTDIR    (0x80000000)
  300. #define M_FILEONLY    (0x40000000)
  301. #define M_HASHDIR    (0x20000000)
  302. #define M_TREEDIR    (0x10000000)
  303. #define M_UNTAGGED    (0x08000000)
  304. #define M_BITMAP    (0x04000000)
  305. #define M_EXTRNFILE    (0x02000000)
  306. #define M_PREALLOC    (0x01000000)
  307. #define M_ZIPFILE    (0x00800000)
  308. #define M_ZIPDATA    (0x00400000)
  309. #define M_CHUNK        (0x00200000)
  310. #define M_VALUE        (0x00100000)
  311. #define M_IFMT        (0x0000F000)
  312. #define M_IFREG        (0x00008000)
  313. #define M_IFDIR        (0x00004000)
  314. #define M_IFIFO        (0x00002000)
  315. #define M_IFCHR        (0x00001000)
  316. #define M_IFBLK        (0x00003000)
  317. #define M_IREAD        (0x00000100)
  318. #define M_IWRITE    (0x00000080)
  319. #define M_IEXEC        (0x00000040)
  320.  
  321.  
  322. extern void *PERMCAT;
  323. extern void *PERMINFO;
  324. extern void *PERMFILE;
  325. extern void *MEMTEMP;
  326. #define MEMTMP MEMTEMP
  327.  
  328. extern char *cff_version;
  329. extern char *cff_copyright;
  330.  
  331.  
  332. #ifdef __cplusplus
  333. extern "C" {
  334. #endif
  335.  
  336. /* STDIO STUFF */
  337. #define __BUFSIZ_  4096
  338.  
  339. extern  struct  cf_iobuf {
  340.     int      _cnt;
  341.     char*    _ptr;
  342.     char*    _base;
  343.     int         _bufsiz;
  344.     short         _flag;
  345.     unsigned char _file;
  346.     char     _sbuf;
  347. } cf_iob[];
  348. extern void *cf_filelist[];
  349.  
  350. typedef struct cf_iobuf cfFILE;
  351.  
  352. #define cf_IOFBF    00000
  353. #define cf_IOREAD   00001
  354. #define cf_IOWRT    00002
  355. #define cf_IONBF    00004
  356. #define cf_IOMYBUF  00010
  357. #define cf_IOEOF    00020
  358. #define cf_IOERR    00040
  359. #define cf_IOSTRG   00100
  360. #define cf_IOLBF    00200
  361. #define cf_IORW     00400
  362. #define cf_IOAPPEND 01000
  363. #define cf_IOTEXT   02000  /*